#ifndef _RAII_H_
#define _RAII_H_

#include <functional>

namespace Engine2D
{
    class RAII
    {
    public:
        using FuncType = std::function<void(void)>;
    public:
        RAII(FuncType && detachFn, FuncType && attach = []() {})
            : m_detachFn(detachFn) { attach(); }
        virtual ~RAII() {
            m_detachFn();
        }
    private:
        std::function<void(void)> m_detachFn;
    };

} // namespace Engine2D


#endif